﻿using FarmSmartSleep.Common.Dtos;
using FarmSmartSleep.Organ.API.Application.Commands.EnterpriseCommands;
using FarmSmartSleep.Organ.API.Application.RaiseCommands;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace FarmSmartSleep.Organ.API.Controllers
{
    /// <summary>
    /// 羊只管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class RaiseController : ControllerBase
    {
        /// <summary>
        /// 获取死亡原因
        /// </summary>
        public readonly IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public RaiseController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 死亡原因下拉框
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<Result> Handle()
        {
            RaiseTypeCommand command = new RaiseTypeCommand();
            return await this.mediator.Send(command);
        }

        /// <summary>
        /// 淘汰原因下拉框
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<Result> Handle1()
        {
            EliminateTypeCommand command = new EliminateTypeCommand();
            return await this.mediator.Send(command);
        }

        /// <summary>
        /// 批量添加羊只死亡
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<Result> AddSheepDeath(RaiseCreateCommand request)
        {
            return await this.mediator.Send(request);
        }

        /// <summary>
        /// 死亡列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost("DeathSelect")]
        public async Task<Result> Handle(RaiseSelectCommand request)
        {
            return await this.mediator.Send(request);
        }


        /// <summary>
        /// 淘汰新增
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("EliminateCreate")]
        public async Task<Result> Handle(EliminateCreateCommand request)
        {
            return await this.mediator.Send(request);
        }


        /// <summary>
        /// 淘汰列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("EliminateSelect")]
        public async Task<Result> Handle(EliminateSelectCommand request)
        {
            return await this.mediator.Send(request);
        }
    }
}
